import request from '@/utils/request'

export function findLeftList(param) {
  return request({
    url: '/folder/leftList',
    method: 'get',
    params: param
  })
}

export function findFileListByFolderId(query) {
  return request({
    url: '/folder/findFileListByFolderId',
    method: 'post',
    data: query
  })
}
// 打开收藏首页
export function openCollectionHome(query) {
  return request({
    url: '/folder/openCollectionHome',
    method: 'get',
    params: query
  })
}

// 加入收藏
export function insertCollection(fileDirId, fileDirType) {
  const data = {
    fileDirId,
    fileDirType
  }
  return request({
    url: '/folder/insertCollection',
    method: 'post',
    data: data
  })
}

// 取消收藏
export function cancelCollection(id) {
  return request({
    url: '/folder/cancelCollection/' + id,
    method: 'get'
  })
}

// 重命名附件
export function renameFile(fileBase) {
  return request({
    url: '/folder/renameFile',
    method: 'get',
    params: fileBase
  })
}

// 显示回收站(首页)
export function theRecycleBin(query) {
  return request({
    url: '/folder/theRecycleBin',
    method: 'get',
    params: query
  })
}

// 修改新上传的文件的File_id
export function updateFileId(fileList) {
  return request({
    url: '/folder/updateFileId',
    method: 'post',
    data: fileList
  })
}

export function updateFileIdSingle(fileBase) {
  return request({
    url: '/folder/updateFileIdSingle',
    method: 'post',
    data: fileBase
  })
}

// 新建文件夹
export function saveFileDir(data) {
  return request({
    url: '/folder/saveDirRole',
    method: 'post',
    data: data
  })
}

// 查询文档库目录详细
export function getFileFolder(id) {
  return request({
    url: '/folder/' + id,
    method: 'get'
  })
}

/**
 * 删除文档库目录
 * @param delId   要删除的目录
 * @param id      要删除的目录id及其所有子目录id
 * @param belong  目录所属模块
 */
export function delFileFolder(delId, id, belong) {
  return request({
    url: '/folder/' + delId + '/' + id + '/' + belong,
    method: 'delete'
  })
}

// 删除文件
export function deleteFileBase(id) {
  return request({
    url: '/folder/deleteFileBase/' + id,
    method: 'delete'
  })
}

// 回收站还原文件
export function recycleBinFile(listId) {
  return request({
    url: '/folder/recycleBinFile/' + listId,
    method: 'get'
  })
}

// 移动文件
export function moveFileToOther(param) {
  return request({
    url: '/folder/moveFileToOther',
    method: 'get',
    params: param
  })
}

// 批量移动文件
export function bulkMoveFile(data) {
  return request({
    url: '/folder/bulkMoveFile',
    method: 'post',
    data: data
  })
}

// 复制文件
export function copyFileToOther(param) {
  return request({
    url: '/folder/copyFileToOther',
    method: 'get',
    params: param
  })
}

// 表单中 加载上传的类型下拉内容
export function fileClassTreeStructure(query) {
  return request({
    url: '/folder/fileClassTreeStructure',
    method: 'get',
    params: query
  })
}

// 表单中 加载上传的类型下拉内容
export function fileClassTreeStructureSearch(query) {
  return request({
    url: '/folder/fileClassTreeStructureSearch',
    method: 'get',
    params: query
  })
}

/**
 * 角色页面权限配置 列表数据
 */
export function leftListSysMenuConfigList(query) {
  return request({
    url: '/folder/leftListSysMenuConfigList',
    method: 'get',
    params: query
  })
}

/**
 * 角色页面权限配置 保存数据
 */
export function saveSysMenuConfig(data) {
  return request({
    url: '/folder/saveSysMenuConfig',
    method: 'post',
    data: data
  })
}

// 根据类型查询对应的模板数据(无权限)
export function getFilesByBusinessType(query) {
  return request({
    url: '/folder/getFilesByBusinessType',
    method: 'get',
    params: query
  })
}

// 查看文件或目录的操作日志
export function fundListRecord(query) {
  return request({
    url: '/folder/fundListRecord/',
    method: 'get',
    params: query
  })
}

// 查看文件或目录的操作日志
export function getDirByBelong(belong) {
  return request({
    url: '/folder/getDirByBelong/' + belong,
    method: 'get'
  })
}

// 批量删除
export function batchDeletion(id) {
  return request({
    url: '/folder/batchDeletion/' + id,
    method: 'delete'
  })
}

// 批量隐藏
export function batchHide(id) {
  return request({
    url: '/folder/batchHide/' + id,
    method: 'get'
  })
}

// 批量还原文件
export function restoreEchoFile(data) {
  return request({
    url: '/folder/restoreEchoFile',
    method: 'post',
    data: data
  })
}

// 手动排序
export function sortManually(data) {
  return request({
    url: '/folder/sortManually',
    method: 'post',
    data: data
  })
}

export function findListByIdNotPer(data) {
  return request({
    url: '/folder/findListByIdNotPer',
    method: 'post',
    data: data
  })
}

export function findFileByIdsHavePer(ids) {
  return request({
    url: '/folder/findFileByIdsHavePer',
    method: 'post',
    data: { fileId: ids }
  })
}

// 导出文档库角色
export function exportFolderRole() {
  return request({
    url: '/folder/exportFolderRole',
    method: 'get'
  })
}

export function findListMobile(query) {
  return request({
    url: '/folder/findListMobile',
    method: 'get',
    params: query
  })
}

export function sqlGetParentFolderBySubId(query) {
  return request({
    url: '/folder/sqlGetParentFolderBySubId',
    method: 'get',
    params: query
  })
}

export function checkFolderPermission(folderId, businessId) {
  return request({
    url: '/folder/checkFolderPermission/' + folderId + '/' + businessId,
    method: 'get'
  })
}
